*SIC- NACE correspondence
clear all

import excel using "SIC_NACE.xlsx",firstrow sheet("Blad6")

tostring NACE2nodot, replace
replace NACE2nodot="0"+NACE2nodot if NACE2<10
g length=strlen(NACE2nodot)

replace NACE2nodot=NACE2nodot+"0" if length==3 
replace NACE2nodot=NACE2nodot+"00" if length==2

keep SIC NACE2nodot
rename NACE2nodot sni2007_4d
rename SIC sic1987

bysort sic1987 sni2007_4d:g flag=_N

bysort sic1987:egen max_flag=max(flag)
keep if flag==max_flag

duplicates drop sic1987 sni2007_4d , force
drop flag max_flag

save "SIC_NACE_correspondence.dta", replace



